home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Mode Examples / Csh-Example.csh < prev    next >
Encoding:
Text File  |  2000-10-30  |  6.3 KB  |  203 lines

  1. ## -*-Csh-*-
  2.  # ==========================================================================
  3.  # Csh-Example.csh
  4.  # 
  5.  # Distributed as an example of Alpha's Csh mode.
  6.  #
  7.  # Csh mode is available at
  8.  # 
  9.  # <http://www.princeton.edu/~cupright/computing/alpha/>
  10.  # ==========================================================================
  11.  ##
  12.  
  13. #!/usr/princeton/bin/tcsh
  14.  # ==========================================================================
  15.  #  Corporate Policies Analysis - Exploring 30 years of family benefits
  16.  # 
  17.  #  FILE: "cps-master.csh"
  18.  #                                    created: 09/25/99 {10:46:22 pm} 
  19.  #                                last update: 08/22/00 {01:22:07 pm} 
  20.  #  Description: 
  21.  # 
  22.  #  The master source file for beginning analysis of data extracted from
  23.  #  the Current Population Surveys CD-ROMs.  This source file should be run
  24.  #  from the Unix folder benefits/cps/analysis, which assumes that the data
  25.  #  files to be analyzed are contained in the folder benefits/cps/data.  To
  26.  #  use this file, type
  27.  #
  28.  #  % source cps-master.csh
  29.  #
  30.  #  where % indicates the Unix prompt.  
  31.  # 
  32.  #  Author: Craig Barton Upright
  33.  #  E-mail: <cupright@princeton.edu>
  34.  #    mail: Princeton University, Department of Sociology
  35.  #          Princeton, New Jersey 08544
  36.  #     www: <http://www.princeton.edu/~cupright>
  37.  #  
  38.  # Copyright (c) 1999-2000  Craig Barton Upright
  39.  # 
  40.  # ==========================================================================
  41.  ##
  42.  
  43.  
  44. ### Preliminaries
  45.  
  46. # This analysis requires some sharp spikes in memory requirements.
  47. # For this reason I monitor the directory size, and keep
  48. # intermediate data files in a scratch directory.
  49.  
  50.  
  51.     unalias rm
  52.  
  53.  
  54. # Making Stata "nice", which lowers its priority for CPU time.
  55. # This keeps our friends at CIT happier.
  56.  
  57.     alias stata nice stata -q
  58.  
  59.  
  60. # Creating symbolic links to scratch files.  Each data file is much too
  61. # large to keep in a personal Unix account.  (In fact, they're so large
  62. # that I have to compress them even in the scratch folder as soon as I can
  63. # throughout the analysis.)  This source file assumes that the extracted
  64. # data files are already in a scratch directory named "benefits-cps"
  65.  
  66.     mkdir   /var/scratch/benefits-cps
  67.  
  68.     rm -f    ../data-temp
  69.     ln -s    /var/scratch/benefits-cps/  ../data-temp/
  70.  
  71.     mkdir    ../data
  72.  
  73. # Creating additional directory "output"
  74.  
  75.     mkdir ../output
  76.  
  77.     
  78. # Removing intermediate data files.
  79. #
  80. # "rm" is necessary because Stata will not overwrite unless specifically
  81. # told to do so, and (except for figures), I generally don't.
  82.  
  83.     rm -f       ../data-temp/*-1.1.dta*
  84.     rm -f       ../data-temp/*-1.2.dta*
  85.     rm -f       ../data-temp/*-1.3.dta*
  86.     rm -f       ../data-temp/*-1.4.dta*
  87.     rm -f       ../data-temp/*-1.5.dta*
  88.     
  89.  
  90. ### Analysis, part I: reading in data, transforming variables
  91. #
  92. # (1-0.do) "Stata-compressing" the marXX.dta data files.
  93. # (1-1.do) Selects variables to be used in the analysis.
  94. #       Recodes variable responses from "_state" to create "region".
  95. #       Adjusts weights according to instructions in appendix Q.
  96. #       (This involves eliminating some observations from the 1963
  97. #       through 1975 data sets which were assigned negative weights.  
  98. #       The output file will indicate how many observations were
  99. #       dropped.)  The march files are then removed to save disk
  100. #       space.  (This is done at the very end, at which point we can 
  101. #       assume that the procedure worked.  This same logic continues
  102. #       in the procedures which follow.)
  103. # (1-2.do) Transforms variables to determine parental status.
  104. # (1-3.do) Transforms variables to determine occupation status.
  105. # (1-4.do) Transforms variables to determine industry.
  106. # (1-5.do) Creating dummy variables
  107.  
  108.     echo "Analysis, part I: reading in data, transforming variables"
  109.  
  110.     stata do cps-1-0.do > cps-1-0.out
  111.     stata do cps-1-1.do > cps-1-1.out
  112.     stata do cps-1-2.do > cps-1-2.out
  113.     stata do cps-1-3.do > cps-1-3.out
  114.     stata do cps-1-4.do > cps-1-4.out
  115.     stata do cps-1-5.do > cps-1-5.out
  116.  
  117.  
  118. # cleaning up after part I:  removing intermediate data files
  119.  
  120.     rm -f  ../data-temp/cps*-1.1*
  121.     rm -f  ../data-temp/cps*-1.2*
  122.     rm -f  ../data-temp/cps*-1.3*
  123.     rm -f  ../data-temp/cps*-1.4*
  124.  
  125.  
  126. ### Analysis, part II: creating crosstab data files
  127. #
  128. # (2-1.do) Extracting, merging crosstab information, national data
  129. # (2-2.do) Extracting, merging crosstab information, regional data
  130. # (2-3.do) Creating new variables as specified by Erin, national data
  131. # (2-4.do) Creating new variables as specified by Erin, regional data
  132. # (2-5.do) Creating figures with new variables, national data
  133. # (2-6.do) Creating figures with new variables, regional data
  134.  
  135.  
  136.     echo "Analysis, part II: creating crosstab data files"
  137.  
  138.     stata do cps-2-1.do > cps-2-1.out
  139.     stata do cps-2-2.do > cps-2-2.out
  140.     stata do cps-2-3.do > cps-2-3.out
  141.     stata do cps-2-4.do > cps-2-4.out
  142.     stata do cps-2-5.do > cps-2-5.out
  143.     stata do cps-2-6.do > cps-2-6.out
  144.  
  145.     
  146. ### Analysis, part III:  merging the new variables with Erin's data set
  147. #
  148. # The "hrs0100.dta.gz" file is from Erin -- it is the one in which all of 
  149. # the new variables will be merged.  It is also rather large, so it has to 
  150. # live in data-temp, the scratch directory.
  151. # (3-1.do) Obtaining the codebook for Erin's data set
  152. # (3-2.do) Merging the new nariables into Erin's stripped data set
  153. # (3-3.do) Merging the new nariables back into Erin's original data set
  154. # (3-4.do) Adding new data, recoding count variables in original data set
  155. # (3-5.do) Creating figures with new variables
  156.  
  157.     echo "Analysis, part III: merging the new variables"
  158.  
  159.     stata do cps-3-1.do > cps-3-1.out
  160.     stata do cps-3-2.do > cps-3-2.out
  161.     stata do cps-3-3.do > cps-3-3.out
  162.     stata do cps-3-4.do > cps-3-4.out
  163.     stata do cps-3-5.do > cps-3-5.out
  164.  
  165.  
  166. # making all cps files world-readable on password protected web site
  167. #
  168. # Edit the .password/.ht* files to change access users and passwords.
  169. # The Unix command "ypmatch username passwd" will give 
  170. # encrypted passwords on this system.
  171.  
  172.     echo "making files world-readable on password protected web site"
  173.     chmod -R 755 ../*
  174.  
  175.  
  176. ### Cleaning up
  177.  
  178.     mv *.out  ../output
  179.  
  180.     rm -f       ../figures/NMomAll*
  181.     rm -f       ../figures/NWomAll*
  182.     rm -f       ../figures/NMomWom*
  183.     rm -f       ../figures/NParAll*
  184.  
  185.     gzip ../data/hrs0100.dta
  186.     
  187.     echo "current inst-logics directory size:" `du -ksd ../`
  188.  
  189.  
  190. # Locating errors:  Useful if run in background
  191.  
  192.     echo "locating errors ..."
  193.     grep 'r(' ../output/* | cat
  194.     echo "finished looking for errors"
  195.  
  196.     
  197. # never comment out this last line!!
  198.  
  199.  
  200.     alias rm rm -i
  201.  
  202. # .